package com.assessment.servermanager.controller;

import javax.servlet.http.HttpServletResponse;

import com.assessment.servermanager.commen.controller.BaseController;
import com.assessment.servermanager.commen.entity.AjaxResult;
import com.assessment.servermanager.commen.entity.PageQuery;
import com.assessment.servermanager.commen.page.TableDataInfo;
import com.assessment.servermanager.entity.TbSign;
import com.assessment.servermanager.entity.bo.TbSignBo;
import com.assessment.servermanager.entity.vo.TbSignVo;
import com.assessment.servermanager.service.ITbSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author jiajia
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/sign")
public class TbSignController extends BaseController {
    @Autowired
    private ITbSignService tbSignService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo<TbSignVo> list(TbSignBo tbSignBo, PageQuery pageQuery) {
        return tbSignService.selectTbSignList(tbSignBo,pageQuery);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbSign tbSign) {
        /*List<TbSign> list = tbSignService.selectTbSignList(tbSign);
        ExcelUtil<TbSign> util = new ExcelUtil<TbSign>(TbSign.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");*/
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tbSignService.selectTbSignById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping
    public AjaxResult add(@RequestBody TbSign tbSign) {
        return toAjax(tbSignService.insertTbSign(tbSign));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TbSign tbSign) {
        return toAjax(tbSignService.updateTbSign(tbSign));
    }

    /**
     * 删除【请填写功能名称】
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tbSignService.deleteTbSignByIds(ids));
    }

    /**
     * 考勤统计
     */
    @GetMapping("/signTotalCount")
    public AjaxResult signTotalCount(@RequestParam(value = "years",required=false) Integer years,@RequestParam(value = "month",required=false)Integer month){
        return AjaxResult.success(tbSignService.signTotalCount(years,month));
    }
}
